package com.fire.service.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fire.bo.supplier.req.ProductReq;
import com.fire.bo.supplier.req.ProductStatusReq;
import com.fire.bo.supplier.req.SupplierListReq;
import com.fire.bo.supplier.req.SupplierReq;
import com.fire.bo.supplier.res.ProductRes;
import com.fire.bo.supplier.res.SupplierListRes;
import com.fire.dao.SupplierDao;
import com.fire.service.SupplierService;

@Service
public class SupplierServiceImpl implements SupplierService
{

	@Autowired
	private SupplierDao supplierDao;
	
	@Override
	public void updateSupplierUser(SupplierListRes bean) throws SQLException
	{
		supplierDao.updateSupplierUser(bean);
	}

	@Override
	public void updateSupplierReq(SupplierReq bean) throws SQLException
	{
		SupplierListRes info = new SupplierListRes();
		info.setId(bean.getUserId());
		info.setSignStatus(bean.getSignStatus());
		supplierDao.updateSupplierUser(info);
		supplierDao.updateSupplierReq(bean);
	}

	@Override
	public List<SupplierListRes> supplierList(SupplierListReq bean) throws SQLException {
		bean.setPage((bean.getPage() - 1) * bean.getPageSize());
		return supplierDao.supplierList(bean);
	}

	@Override
	public List<ProductRes> productList(ProductReq bean) throws SQLException {
		
		bean.setPage((bean.getPage() - 1) * bean.getPageSize());
		return supplierDao.productList(bean);
	}

	@Override
	public void updateProductReq(ProductStatusReq bean) throws SQLException {
		supplierDao.updateProductReq(bean);
	}

	@Override
	public int productListCount(ProductReq bean) throws SQLException {
		return supplierDao.productListCount(bean);
	}

	@Override
	public int supplierListCount(SupplierListReq bean) throws SQLException {
		return supplierDao.supplierListCount(bean);
	}

}
